This lesson is being piloted (Beta version)

Introduction to Keras

Overview

Teaching: 20 min
Exercises: 0 min
Questions
  • What are different component in Keras

Objectives
  • Learn different component in Keras

Import Keras

import keras

Layers in Deep Learning

image

For regular Deep Learning model, we use fully connected or Dense layer:

from keras.models import Sequential
from keras.layers import Dense

Sequential

Dense:

image

Dense implements the operation: output = activation(dot(input, kernel) + bias); where:

Create a Sequential model with N=2 as in image above:

# Create a Sequential model
model = Sequential()
# Create a first hidden layer, the input for the first hidden layer is input layer which has 3 variables:
model.add(Dense(5, activation='relu', input_shape=(3,)))
# Create a second hidden layer without specifying input_shape
model.add(Dense(4, activation='relu'))
# Create an output layer:
model.add(Dense(2,activation='sigmoid'))

How about this model?

image

Optimal activation function?

For hidden layers:

image

For output layers:

image

Source on optimal activation function can be found here

Key Points

  • Layers, model, Dense